import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDPetWake {
	/**等级，pet.wakeBaseid+等级*/
	id,
	/**阶段*/
	stage,
	/**阶段*/
	level,
	/**最大等级*/
	maxLevel,
	/**消耗道具*/
	costItem,
	/**消耗道具数量*/
	costNum,
	/**返还道具1*/
	backItem1,
	/**返还数量1*/
	backNum1,
	/**返还道具2*/
	backItem2,
	/**返还数量2*/
	backNum2,
	/**返还道具3*/
	backItem3,
	/**返还数量3*/
	backNum3,

	/**枚举数量*/
	EnumCount
}



export class CDPetWake{
	/**等级，pet.wakeBaseid+等级*/
	public id: number;
	/**阶段*/
	public stage: number;
	/**阶段*/
	public level: number;
	/**最大等级*/
	public maxLevel: number;
	/**消耗道具*/
	public costItem: number;
	/**消耗道具数量*/
	public costNum: number;
	/**返还道具1*/
	public backItem1: number;
	/**返还数量1*/
	public backNum1: number;
	/**返还道具2*/
	public backItem2: number;
	/**返还数量2*/
	public backNum2: number;
	/**返还道具3*/
	public backItem3: number;
	/**返还数量3*/
	public backNum3: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDPetWake.id: return this.id;
			case E_CDPetWake.stage: return this.stage;
			case E_CDPetWake.level: return this.level;
			case E_CDPetWake.maxLevel: return this.maxLevel;
			case E_CDPetWake.costItem: return this.costItem;
			case E_CDPetWake.costNum: return this.costNum;
			case E_CDPetWake.backItem1: return this.backItem1;
			case E_CDPetWake.backNum1: return this.backNum1;
			case E_CDPetWake.backItem2: return this.backItem2;
			case E_CDPetWake.backNum2: return this.backNum2;
			case E_CDPetWake.backItem3: return this.backItem3;
			case E_CDPetWake.backNum3: return this.backNum3;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDPetWake.id: this.id = v; break;
			case E_CDPetWake.stage: this.stage = v; break;
			case E_CDPetWake.level: this.level = v; break;
			case E_CDPetWake.maxLevel: this.maxLevel = v; break;
			case E_CDPetWake.costItem: this.costItem = v; break;
			case E_CDPetWake.costNum: this.costNum = v; break;
			case E_CDPetWake.backItem1: this.backItem1 = v; break;
			case E_CDPetWake.backNum1: this.backNum1 = v; break;
			case E_CDPetWake.backItem2: this.backItem2 = v; break;
			case E_CDPetWake.backNum2: this.backNum2 = v; break;
			case E_CDPetWake.backItem3: this.backItem3 = v; break;
			case E_CDPetWake.backNum3: this.backNum3 = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDPetWake> = new HashMap<number, CDPetWake>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDPetWake[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDPetWake();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].stage = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].level = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].maxLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backItem1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backItem2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backItem3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum3 = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDPetWake{
		return this.datas ? this.datas.get(id) : null;
	}
}
